Adjust custom target test for workspace-relative hashing
authorTyler Hall <tylerwhall@gmail.com>
Sun, 29 Jan 2017 22:55:38 +0000 (17:55 -0500)
committerTyler Hall <tyler.hall@lexmark.com>
Sun, 25 Jun 2017 21:45:08 +0000 (17:45 -0400)
Switching to workspace-relative metadata hashing means that output can
change based on what is considered to be the top-level crate. This test
is affected by this change, but in general hashes should be more stable
than before.

This test verifies that a crate will not rebuild when built as a
dependency of two different crates but with the same CARGO_TARGET_DIR.
This currently relies on the absolute path to the crate being the same
across runs. Set an explicit workspace so the hashes will be the same
when using workspace-relative hashing.

Setting a workspace would cause the target dir to be the same in both
invocations, defeating the intent of this test, so move the target dir
between runs to verify that the contents of the target dir are not
dependent on its path.

tests/path.rs

index 16335e2168a5e87cd7b2a0826af2a37681c66c50..97ccac7b19a8399995b6afaed19eee0d3d300ec1 100644 (file)
@@ -1,4 +1,5 @@
 extern crate cargo;
+#[macro_use]
 extern crate cargotest;
 extern crate hamcrest;
 
@@ -808,6 +809,8 @@ fn custom_target_no_rebuild() {
             authors = []
             [dependencies]
             a = { path = "a" }
+            [workspace]
+            members = ["a", "b"]
         "#)
         .file("src/lib.rs", "")
         .file("a/Cargo.toml", r#"
@@ -835,9 +838,10 @@ fn custom_target_no_rebuild() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 "));
 
+    t!(fs::rename(p.root().join("target"), p.root().join("target_moved")));
     assert_that(p.cargo("build")
                  .arg("--manifest-path=b/Cargo.toml")
-                 .env("CARGO_TARGET_DIR", "target"),
+                 .env("CARGO_TARGET_DIR", "target_moved"),
                 execs().with_status(0)
                        .with_stderr("\
 [COMPILING] b v0.5.0 ([..])